package com.jsgt.greekfire.dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.view.WindowManager;

/**
 * Created by qingning on 2016/8/31.
 */
public abstract class BaseDialog extends Dialog{
    int statusBarColor = 0;
    protected boolean flagFullScreen;
    protected BaseDialog(Context context) {
        super(context);
    }
    protected BaseDialog(Context context, int themeResId) {
        super(context, themeResId);
    }
    protected BaseDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            if(flagFullScreen) {
                getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
            }else{
                getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            }
            getWindow().setStatusBarColor(statusBarColor);
        }
    }

    protected boolean _canceledOnTouchOutside;
    @Override
    public void setCanceledOnTouchOutside(boolean cancel) {
        this._canceledOnTouchOutside = cancel;
        super.setCanceledOnTouchOutside(cancel);
    }

    protected <T> T $(int viewID) {
        return (T) findViewById(viewID);
    }
}
